local hashKey = KEYS[1]
local field = ARGV[1]        -- 产品ID
local decrement = tonumber(ARGV[2]) -- 扣减数量

local currentStock = tonumber(redis.call('HGET', hashKey, field))
if currentStock and currentStock >= decrement then
    redis.call('HINCRBY', hashKey, field, -decrement)
    return 1
else
    return 0
end
